from django import template
from django.db.models import Count
from ..models import Case,Person

register = template.Library()

@register.simple_tag
def total_people():
    return Person.objects.count()

@register.simple_tag
def peopleofcase(id):
    num = Case.objects.annotate(numofpeople=Count('person')).get(pk=id).numofpeople
    return num

@register.inclusion_tag('people/casepeople.html')
def casepeople(case):
    casepeople = Person.objects.filter(case=case)
    return locals()
